<template>
  <div>
    <van-search
      v-model="value"
      show-action
      label="上海"
      placeholder="请输入小区或地址"
      background="#21b97a"
      
    >
      <template #action>
        <div ><van-icon name="aim" size="25" color="#fff"/></div>
      </template>
    </van-search>
    <div class="findList">
      <ul>
        <li v-for="item in info" :key="item.title" @click="toDetail">
          <div class="imgs"><img src="../img/图1.webp" alt="" /></div>
          <div class="list-content">
            <h3>{{ item.title }}</h3>
            <p class="adress">{{ item.desc }}</p>
            <p class="distance">{{ item.tags[0] }}</p>
            <div class="housePrice">
              <span>{{ item.price }}</span
              >元/月
            </div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import axios from 'axios';
export default {
  name: 'List',
  data() {
    return {
      info: null,
    };
  },
  methods: {
    toDetail() {
      this.$router.push(
        {
          name: 'detail',
        },
        () => {}
      );
    },
  },
  async created() {
    const { data } = await axios({
      url: 'http://liufusong.top:8080/houses?cityId=AREA%7Cdbf46d32-7e76-1196&stat=1&end=10',
    });
    console.log(data);
    this.info = data.body.list;
  },
};
</script>

<style scoped lang="less">
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
.findList {
  ul {
    width: 100%;
    li {
      height: 120px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom: 1px solid #ccc;
      padding: 15px;
      .imgs {
        width: 120px;
        height: 100%;
        background-color: brown;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .list-content {
        flex: 1;
        height: 100%;
        margin-left: 10px;
        font-size: 12px;
        h3 {
          font-size: 15px;
          color: #394043;
        }
        .adress {
          color: #afb2b3;
          margin: 5px 0;
        }
        .distance {
          width: 50px;
          height: 25px;
          background-color: #e1f5f8;
          border-radius: 3px;
          color: #39becd;
          text-align: center;
          line-height: 25px;
          margin-bottom: 5px;
        }
        .housePrice {
          color: #fa5741;
          span {
            font-size: 16px;
          }
        }
      }
    }
  }
}
</style>
